<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>3-求数组中相应数据类型的元素个数</title>
	</head>
	<body>
<script type="text/javascript">
	//var arr = new Array();
	//1.初始化一个数组并赋值
	var arr = ['abc',22,'dasdsa',true,'dsawo','中国',12,13,14,339.98,true,false,''];
	//数据类型 string number boolean
	//2.声明相关数据类型变量，并将其值初始化为0
	var xstring = 0,xboolean=0,xnumber=0;
	//3.循环数组，进行元素类型比对
	for(var i=0;i<arr.length;i++){
		//将循环的某个元素先提取出来
		var ele = arr[i];
		//判断
		if(typeof ele=='string'){
			xstring++;
		}else if(typeof ele=='number'){
			xnumber++;
		}else if(typeof ele=='boolean'){
			xboolean++;
		}
		//console.log(arr[i]);
	}

/* 	console.log(typeof arr[0]);//string
	console.log(typeof arr[3]);//boolean
	console.log(typeof arr[1]);//number */
	
	console.log("number类型:::"+xnumber);
	console.log("string类型:::"+xstring);
	console.log("boolean类型:::"+xboolean);
	

</script>
	</body>
</html>
